package com.lsj.Service.Impl;

import com.lsj.Dao.AccountDao;
import com.lsj.Service.AccountService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Service("accountService")
//如果一个方法中拥有多个事务 配置相同可以将事务注解书写在类上
//当前类下所有的方法使用同一的事务管理配置
public class AccountServiceImpl implements AccountService {
    private AccountDao accountDao;

    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    //@Transactional
    //事务注解 用于标识当前方法需要进行事务管理 等价于切点表达式识别
    //可以像配置一样通过对应的属性设置隔离级别 传播属性 超时时间 是否只读
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,timeout = -1,readOnly = false)
    public void zz(String out, String in, double money) {
        accountDao.updateSubMoneyByName(out,money);
        System.out.println(1/0);
        accountDao.updateAddMoneyByName(in,money);
    }
}
